/**
 * Project Name:lee
 * File Name:UserloginController.java
 * Package Name:com.lee.system.controller
 * Date:2017年1月5日上午10:46:27
 * Copyright (c) 2017, chenzhou1025@126.com All Rights Reserved.
 *
 */

package com.lee.system.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.lee.annotation.SystemLog;
import com.lee.base.controller.BaseController;
import com.lee.common.page.PageView;
import com.lee.system.model.HandleLog;
import com.lee.system.service.HandleLogService;

/**
 * ClassName:SystemLogController <br/>
 * Function: TODO ADD FUNCTION. <br/>
 * Reason: TODO ADD REASON. <br/>
 * Date: 2017年1月5日 上午10:46:27 <br/>
 * 
 * @author dell
 * @version
 * @since JDK 1.6
 * @see
 */
@Controller
@RequestMapping("/systemLog/")
public class SystemLogController extends BaseController {
	@Autowired
	private HandleLogService handleLogService;

	// to列表
	@RequestMapping("intoHandleLogList")
	public ModelAndView intoHandleLogList() {
		ModelAndView mav = new ModelAndView("/system/systemLog/handleList");
		return mav;
	}
	// to列表
	@RequestMapping("intoErrorLogList")
	public ModelAndView intoErrorLogList() {
		ModelAndView mav = new ModelAndView("/system/systemLog/errorList");
		return mav;
	}

	@ResponseBody
	@RequestMapping("findByPage")
	public PageView findByPage(HandleLog handleLog, String pageNow, String pageSize, String column, String sort) throws Exception {
		Map<String, Object> map = new HashMap<String, Object>();
		map = toFormMap(pageNow, pageSize);
		map.put("column", column);
		map.put("sort", sort);
		map.put("handleLog", handleLog);
		List<HandleLog> list = handleLogService.findByPage(map);
		int count = handleLogService.count(handleLog);
		pageView.setRecords(list);
		pageView.setRowCount(count);
		return pageView;
	}
	
	@SystemLog(module="系统管理",methods="删除操作日志")
	@RequestMapping("del")
	@ResponseBody
	public String del(HttpServletRequest request, int id) {
		String flag = "false";
		int i = handleLogService.delete(id, true);
		if (i > 0) {
			flag = "true";
		}
		return flag;
	}
}
